1. Field of the Invention
This invention relates to the field of application programming interfaces, and, more particularly to a system and method of writing portable multithreaded application programs by creating and combining independent agents.
2. Description of the Related Art
An application programming interface provides a method for programmers to write application programs that run on a particular hardware system. Typically an application programming interface is customized to run on a particular hardware platform. An application programming interface provides system calls to perform certain hardware dependent functions such as getting keyboard input or writing to disk. An application programming interface also provides calls for an application to interface to the platform's user interface, for example, a call to open a window. Therefore, the application programmer can use the calls provided by the application programming interface for performing hardware dependent and user interface functions. This saves the application programmer the time involved in writing hardware dependent and user interface functions; the application programmer need only write the code specific to the application, and may rely on the calls provided by the application programming interface to perform system related functions.
An application program written for a specific application programming interface cannot be ported to another platform with a different application programming interface without replacing all of the system calls for the original application programming interface. It takes a programmer additional time to rewrite these sections of the application program. After the system calls are replaced, the application program is recompiled. It will then run on the platform with the different application programming interface. However, after the changes are made, the application program will then have the user interface look and feel of the programming interface on the new system. The same application program looks different on two different systems because the systems have different user interfaces.
Furthermore, most application programming interfaces do not provide multithreading. Multithreading allows an application program to contain more than one stream of execution; each stream of execution is a thread. Typically, each thread performs a different function within the application program; for example one thread fills a buffer, and another thread reads from the buffer. The application programmer must then rely on the multithreading provided by the operating system on the platform. Some operating systems may not provide any multithreading at all.
In addition, application programming interfaces provide a scheme for sending messages among components of an application program. For example, when a character is entered at the keyboard, a message may be sent to a window telling the window to display the character. Typically an application programmer cannot modify the message passing framework provided by the application programming interface. As a result, the code for message passing must be modified when an application program is ported to a platform with a different application programming interface. It takes the programmer additional time to replace the message passing code.
An application programming interface may or may not be written in an object-oriented language. If the application programming interface is written in an object-oriented language, then the application programmer may define classes and class hierarchies as specified in the object-oriented programming language. Each class may have some functions associated with the data in the class. In a class hierarchy, classes are organized in chains from the general to the more specific. A more specific subclass is derived from a more general base class. For example, if a dialog box were a type of window, then the dialog box subclass would be derived from the more general window base class.
Application programming interfaces written in object-oriented programming languages have the advantage of allowing the more specific class to maintain its own data and context and relying on the base class to maintain the general data and context. Therefore, a programmer can reuse code which saves time and can write a more consistently organized program because there is less duplicate code. Each class is independent of other classes, even a subclass is independent of its base class(es), because the class does not need to know about the other classes' data.
Application programming interfaces that are written in object-oriented languages have the disadvantage of generating larger programs that require more memory to run. In addition, the application programmer must have a compiler for the object-oriented language to compile the application program. Furthermore, the application programmer must know the object-oriented language and be familiar with object-oriented programming.